package com.ncu.cloundeoffice.service.impl;

import com.ncu.cloundeoffice.mapper.TSalaryMapper;
import com.ncu.cloundeoffice.pojo.ResponseResult;
import com.ncu.cloundeoffice.pojo.TSalary;
import com.ncu.cloundeoffice.service.TSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TSalaryServiceImpl implements TSalaryService {

    @Autowired
    private TSalaryMapper tSalaryMapper;


    /**
     * 查询所有的工资账套
     * @return
     */
    @Override
    public List<TSalary> getAllTSalary() {
        return tSalaryMapper.getAllTSalary();
    }

    /**
     * 删除工资账套
     * @param id
     * @return
     */
    @Override
    public ResponseResult deleteSalaryById(int id) {
        int count = tSalaryMapper.deleteSalaryById(id);
        if(count == 1){
            return ResponseResult.success("删除成功!");
        }
        return ResponseResult.error("删除失败!");
    }

    /**
     * 添加工资账套
     * @param tSalary
     * @return
     */
    @Override
    public ResponseResult addSalary(TSalary tSalary) {
        int count = tSalaryMapper.addSalary(tSalary);
        if(count == 1){
            return ResponseResult.success("添加成功!");
        }
        return ResponseResult.error("添加失败!");
    }

    /**
     * 更新工资账套
     * @param tSalary
     * @return
     */
    @Override
    public ResponseResult updateSalary(TSalary tSalary) {
        int count = tSalaryMapper.updateSalary(tSalary);
        if(count == 1){
            return ResponseResult.success("更新成功!");
        }
        return ResponseResult.error("更新失败!");
    }
}
